Imports Microsoft.VisualBasic

Public Class Sport
    Inherits BizObject
    Sub New(ByVal ID As Integer, ByVal sportName As String)
        _ID = ID
        _sportName = sportName
    End Sub
    Sub New()

    End Sub
    Private _ID As Integer
    Public Property ID() As Integer
        Get
            Return _ID
        End Get
        Set(ByVal value As Integer)
            _ID = value
        End Set
    End Property

    Private _sportName As String
    Public Property sportName() As String
        Get
            Return _sportName
        End Get
        Set(ByVal value As String)
            _sportName = value
        End Set
    End Property
    Public Function Delete() As Boolean
        Return DeleteSport(Me.ID)
    End Function
    Public Shared Function DeleteSport(ByVal ID As Integer) As Boolean
        Return Sport.DeleteSport(ID)
    End Function
    Public Function ToSportDetails(ByVal TargetSport As SportDetails) As SportDetails
        Dim NewSportDetails As New SportDetails
        With NewSportDetails
            .ID = Me.ID
            .sportName = Me.sportName
        End With
        Return NewSportDetails
    End Function
    Public Shared Function FromSportDetails(ByVal SourceSportDetails As SportDetails) As Sport
        With SourceSportDetails
            Dim NewSport As New Sport(.ID, .sportName)
            Return NewSport
        End With
    End Function
    Public Function Update() As Boolean
        Return UpdateSport(ID, sportName)
    End Function
    Public Function Update(ByVal Sport As SportDetails) As Boolean
        With Sport
            Return UpdateSport(.ID, sportName)
        End With
    End Function
    Public Shared Function UpdateSport(ByVal ID As Integer, ByVal sportName As String) As Boolean
        sportName = BizObject.FixNull(sportName)
        Dim record As New SportDetails(ID, sportName)
        Return SiteProvider.Sports.UpdateSport(record)
    End Function
    Public Shared Function CreateSport(ByVal sportName As String) As Integer
        sportName = BizObject.FixNull(sportName)
        Dim record2 As New SportDetails(0, sportName)
        Return SiteProvider.Sports.CreateSport(record2)
    End Function
    Public Function Create() As Integer
        _ID = CreateSport(_sportName)
        Return _ID
    End Function
    Public Shared Function GetSport(ByVal SportID As Integer) As Sport
        Return FromSportDetails(SiteProvider.Sports.GetSport(SportID))
    End Function
    Public Shared Function GetSportsList() As Generic.List(Of Sport)
        Dim SportDetailsList As Generic.List(Of SportDetails)
        Dim SportList As New Generic.List(Of Sport)
        SportDetailsList = SiteProvider.Sports.GetSports()
        Dim g As SportDetails
        For Each g In SportDetailsList
            SportList.Add(FromSportDetails(g))
        Next
        Return SportList
    End Function
End Class
